
public class exercise9_11 {
    private double a, b, c, d, e, f;

    public exercise9_11(double a, double b, double c,
                        double d, double e, double f) {
        this.a = a; this.b = b; this.c = c;
        this.d = d; this.e = e; this.f = f;
    }

    public double getA() { return a; }
    public double getB() { return b; }
    public double getC() { return c; }
    public double getD() { return d; }
    public double getE() { return e; }
    public double getF() { return f; }

    public boolean isSolvable() {
        return a * d - b * c != 0;
    }

    public double getX() {
        return (e * d - b * f) / (a * d - b * c);
    }

    public double getY() {
        return (a * f - e * c) / (a * d - b * c);
    }

    public static void main(String[] args) {
        java.util.Scanner in = new java.util.Scanner(System.in);
        System.out.print("Enter a, b, c, d, e, f: ");
        double a = in.nextDouble();
        double b = in.nextDouble();
        double c = in.nextDouble();
        double d = in.nextDouble();
        double e = in.nextDouble();
        double f = in.nextDouble();

        exercise9_11 eq = new exercise9_11(a, b, c, d, e, f);
        if (eq.isSolvable()) {
            System.out.printf("x=%.4f  y=%.4f%n", eq.getX(), eq.getY());
        } else {
            System.out.println("The equation has no solution.");
        }
    }
}